/**
* This file is part of OntoApplications (project linked with OntoCompoFramework)
*
* Copyright (C) 2011 -  Christian Brel
*
* @author   Main    Christian Brel
**/
package applications.trimstring.fc.lib;

import java.util.Observable;

import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;

import ontocompo.api.OntoCompoIntrospection;

import applications.trimstring.fc.api.TrimStringService;

@Component(provides = {@Interface(name = "trimstringservice", signature = applications.trimstring.fc.api.TrimStringService.class), @Interface(name = "observable", signature = ontocompo.api.Observable.class), @Interface(name = "ontocompointrospection", signature = ontocompo.api.OntoCompoIntrospection.class)})
public class TrimStringServiceImpl extends Observable implements TrimStringService, ontocompo.api.Observable, OntoCompoIntrospection {

	private String uid;
	private org.objectweb.fractal.api.Component c;
	
	private String regex;
	private String str;
	
	public TrimStringServiceImpl() {
		this.uid = "applications.trimstring.fc.lib.TrimStringServiceImpl";
	}
	
	@Override
	public String trim() {
		// TODO Auto-generated method stub
		System.out.println("LE TrimString SERVICE TRAVAILLE AVEC L'ENTREE SUIVANTE: " + this.str + " et reg = " + this.regex);
		return this.str.replaceAll(this.regex, "");
	}

	@Override
	public void setRegexString(String regex) {
		// TODO Auto-generated method stub
		this.regex = regex;
		if(this.str != null) {
			setChanged();
			notifyObservers();
		}
	}

	@Override
	public void setWorkedString(String str) {
		// TODO Auto-generated method stub
		this.str = str;
		if(this.regex != null) {
			setChanged();
			notifyObservers();
		}
	}
	
	@Override
	public org.objectweb.fractal.api.Component getFractalComponent() {
		// TODO Auto-generated method stub
		return this.c;
	}

	@Override
	public void setFractalComponent(org.objectweb.fractal.api.Component c) {
		// TODO Auto-generated method stub
		this.c = c;
	}
	
	public void clearChanged() {
		super.clearChanged();
	}
	
	public void setChanged() {
		super.setChanged();
	}

	@Override
	public String getUid() {
		// TODO Auto-generated method stub
		return this.uid;
	}

	@Override
	public void setUid(String uid) {
		// TODO Auto-generated method stub
		this.uid = uid;
	}

}
